<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>number数据类型的转换</title>
</head>
<body>
  <script>
    //Number() 转换
    var s1 = '100';
    var s2 = typeof s1;
    console.log(s2);
    //将数据类型转换 不是数字的话会被转换为NaN类型(not a number)
    var n1 = Number(s1);
    console.log(typeof  n1)
    console.log(n1)
    //parseInt()的转换
    var s3 = '100';
    var s4 = typeof s1;
    console.log(s4);
    //转换
    var n2 = parseInt(s3);
    console.log(typeof n2);
    console.log(n2)
    //parseInt()会转换前部分的数字
    var s5 = '100abc'
    var n3 = parseInt(s5);
    console.log(n3);
    //parseFloat 将字符转换为小数
    var s6 = '100.26';
    var n4 = parseFloat(s6);
    console.log(n4);
  </script>
</body>
</html>